<?php
$this->breadcrumbs=array(
	'Reports'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'Create Reports', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('reports-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Reports</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'reports-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
                array(
                    'value'=>'$data[\'report_id\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:40px',
                    ),
                    'name'=>'report_id',
                ),
		'name',
                'ber_docName',
		array(
                    'value'=>'Organisation::model()->findByPK($data[\'org_id\'])->nachname',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:40px',
                    ),
                    'name'=>'org_id',
                ),
                /*array(
                    'value'=>'$data[\'type\']',
                    'type'=>'raw',
                    'htmlOptions'=>array(
                            'style'=>'width:40px',
                    ),
                    'name'=>'type',
                ),		
		'rep_id',
		'mail_subject',
		'mail_body',
		
		's_zyklus',
		's_zyklus_gap',
		's_zylklus_start',
		'production_time',
		's_zyklus_time',
		*/
		array(
                    'class'=>'CButtonColumn',
                    'template'=>'{delete} {update} {beeyeclone}',
                    'buttons'=>array(
                        'beeyeclone'=>array(
                            'url'=>'Yii::app()->createUrl("//reports/beeyeclonereport", array("id" => $data[\'report_id\']))',
                            'label' => 'clone report with new id',
                            'imageUrl'=>Yii::app()->request->baseUrl.'/images/clone.png',
                            'options'=>array(
                                'ajax'=>array(
                                        'type'=>'POST',
                                        'url'=>"js:$(this).attr('href')",
                                        'success'=>"js:$('#Notification').jnotifyAddMessage({
                                            text: 'Report has been cloned...',
                                            permanent: false,
                                            showIcon: true
                                        })",
                                        //'update'=>"#mySubViewForm",
                                    )
                                )
                            ),
                         ),
                     ),
               array(
                    'class'=>'CButtonColumn',
                    'template'=>'{send} {register} {unregister}',
                    'buttons'=>array(
                        'send'=>array(
                            'url'=>'Yii::app()->createUrl("//reports/mailmyreports", array("id" => $data[\'report_id\']))',
                            'label' => 'send report to all recipients',
                            'imageUrl'=>Yii::app()->request->baseUrl.'/images/email.png',
                            'options'=>array(
                                'ajax'=>array(
                                        'type'=>'POST',
                                        'url'=>"js:$(this).attr('href')",
                                        'success'=>"js:$('#Notification').jnotifyAddMessage({
                                            text: 'Report send to all recipients...',
                                            permanent: false,
                                            showIcon: true
                                        })",
                                        //'update'=>"#mySubViewForm",
                                    )
                                )
                            ),
                        'register'=>array(
                            'url'=>'Yii::app()->createUrl("//reports/ReportsRegisterCronJob", array("id" => $data[\'report_id\']))',
                            'label' => 'register report',
                            'imageUrl'=>Yii::app()->request->baseUrl.'/images/connect_established.png',
                            'options'=>array(
                                'ajax'=>array(
                                        'type'=>'POST',
                                        'url'=>"js:$(this).attr('href')",
                                        'success'=>"js:$('#Notification').jnotifyAddMessage({
                                            text: 'Report is now registered...',
                                            permanent: false,
                                            showIcon: false
                                        })",
                                        //'update'=>"#mySubViewForm",
                                    )
                                )
                            ),
                        'unregister'=>array(
                            'url'=>'Yii::app()->createUrl("//reports/ReportsUnregisterCronJob", array("id" => $data[\'report_id\']))',
                            'label' => 'unregister report',
                            'imageUrl'=>Yii::app()->request->baseUrl.'/images/connect_no.png',
                            'options'=>array(
                                'ajax'=>array(
                                        'type'=>'POST',
                                        'url'=>"js:$(this).attr('href')",
                                        'success'=>"js:$('#Notification').jnotifyAddMessage({
                                            text: 'Report is now unregistered...',
                                            permanent: false,
                                            showIcon: false
                                        })",
                                        //'update'=>"#mySubViewForm",
                                    )
                                )
                            ),
                         ),
                     ),
	),
)); ?>
